package com.study.selection.service;

import com.study.selection.dao.StudentDao;
import com.study.selection.model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentDao studentDao;

    @Override
    public List<Student> findAll() {
        return studentDao.findAll();
    }

    @Override
    public List<Student> findByKey(String key) {
        return studentDao.findByKey(key);
    }

    @Override
    public boolean addStudent(Student student) {
        return studentDao.addStudent(student) > 0 ? true : false;
    }

    @Override
    public Student getByStudentId(int studentId) {
        return studentDao.getByStudentId(studentId);
    }
    @Override
    public List<Student>getByCollegeId(int collegeId){
        return studentDao.getByCollegeId(collegeId);
    }
    @Override
    public List<Student>getByClassId(int classId){
        return studentDao.getByClassId(classId);
    }

    @Override
    public List<Student>getByMajorId(int majorId){
        return studentDao.getByMajorId(majorId);
    }
    @Override
    public boolean updateStudent(Student student) {
        return studentDao.updateStudent(student) > 0 ? true : false;
    }
    @Override
    public boolean deleteStudent(int studentId) {
        return studentDao.deleteStudent(studentId) > 0 ? true : false;
    }

}
